package com.chanyachting.emall.serviceImpl;

import java.util.List;

import com.chanyachting.emall.dao.RechargehistoryDAO;
import com.chanyachting.emall.domain.Memberaccount;
import com.chanyachting.emall.domain.Rechargehistory;
import com.chanyachting.emall.service.RechargehistoryService;

public class RechargehistoryServiceImpl implements RechargehistoryService {
	
	private RechargehistoryDAO rhDao;

	public RechargehistoryServiceImpl() {
		
		this.rhDao=new RechargehistoryDAO();
	}

	public boolean createRechargehistory(Rechargehistory rs) {
		
		this.rhDao.save(rs);
		
		return true;
	}

	public List<Rechargehistory> getAllRechargehistory() {
	
		return this.rhDao.find("from Rechargehistory");
	}

	public Rechargehistory getOneRechargehistory(Rechargehistory rs) {
		
		return (Rechargehistory) this.rhDao.load(Rechargehistory.class, rs.getId());
	}

	public List<Rechargehistory> getRechargehistoryByMemberAccount(
			Memberaccount maccount) {
		
		String args[]={String.valueOf(maccount.getId())};
		
		return this.rhDao.find("from Rechargehistory where memberAccountId=?", args);
	}

}
